<template>
    <div class="industry" v-for="(item, key) in state.data" :key="key">
        <div class="industry-name"> 
            {{ key }}
            {{ item.length }}
        </div>
        <div class="stocks">
            <div class="stock" v-for="(subItem, subKey) in item" :key="subKey">
                <table>
                    <tr>
                        <td colspan="6"><a :href="`/#/weekDetail?stock=${subItem.stock}`" target="_blank">{{ subItem.stock }}</a></td>
                    </tr>
                    <tr>
                        <td><a href="/#/wugu"  target="_blank">wg</a></td>
                        <td><a href="/#/lpDetail"  target="_blank">lp</a></td>
                        <td>dPct</td>
                        <td>wPct</td>
                        <td>mPct</td>
                        <td>yPct</td>
                    </tr>
                    <tr>
                        <td v-if="subItem.wg < 100" class="wugu-lt100-cell">{{ subItem.wg }}</td>
                        <td v-else>{{ subItem.wg }}</td>

                        <td v-if="subItem.lp <= 10" class="lplt10-cell">{{ subItem.lp }}</td>
                        <td v-else-if="subItem.lp <= 20" class="lplt20-cell">{{ subItem.lp }}</td>
                        <td v-else-if="subItem.lp >= 99" class="lpgt99-cell">{{ subItem.lp }}</td>
                        <td v-else>{{ subItem.lp }}</td>

                        <td v-if="subItem.dayPct < 0" class="pctlt0-cell">{{ subItem.dayPct }}</td>
                        <td v-else>{{ subItem.dayPct }}</td>

                        <td v-if="subItem.weekPct < 0" class="pctlt0-cell">{{ subItem.weekPct }}</td>
                        <td v-else>{{ subItem.weekPct }}</td>

                        <td v-if="subItem.monthPct < 0" class="pctlt0-cell">{{ subItem.monthPct }}</td>
                        <td v-else>{{ subItem.monthPct }}</td>

                        <td v-if="subItem.yearPct < 0" class="pctlt0-cell">{{ subItem.yearPct }}</td>
                        <td v-else>{{ subItem.yearPct }}</td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</template>

<script>
import { reactive } from 'vue';
import { getIndustryPanorama } from '../../service/industry';

export default {
    components: {
    },
    mounted() {
        document.title = "行业全景"
    },
    setup() {
        const state = reactive({
            data: [],
        })

        getIndustryPanorama().then(res => {
            state.data = res.data
        })

        return {state}
    }
}
</script>

<style scope>
a {
    color: black;
    text-decoration: none; /* 去掉下划线 */
}

a:hover {
  color: red; /* 鼠标悬停时的颜色 */
  text-decoration: underline; /* 添加下划线 */
}

.industry {
    border: none;
    display: flex;
    margin-bottom: 10px;
}

.industry-name {
    flex-shrink: 0; /* 防止缩小 */
    flex-grow: 0; /* 防止放大 */
    width: 200px;
    background: rgb(250, 229, 156);
    border-radius: 15px;
    text-align: center;
    line-height: 80px;
}

table {
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
    border-top: none;
    border-bottom: none;
    width: 150px;
    border-collapse: collapse; /* 合并边框 */
    border-spacing: 0; /* 设置单元格之间的间距 */
}

td {
    border: 1px solid #ccc;
    text-align: center;
    margin: 5px, 0, 5px, 0;
    padding: 3px;
}

.stocks {
    display: flex;
    overflow-x: auto;  /* 横向滑动 */
}

.stock {
    margin-left: 10px;
}
</style>